<?php

/**
 * risque filter form base class.
 *
 * @package    gesp
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaserisqueFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'rsq_prj_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('projet'), 'add_empty' => true)),
      'rsq_cat_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('categorie'), 'add_empty' => true)),
      'rsq_description' => new sfWidgetFormFilterInput(),
      'rsq_date_ident'  => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'rsq_gravite'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('gravite'), 'add_empty' => true)),
      'rsq_proba'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('probabilite'), 'add_empty' => true)),
      'rsq_impact'      => new sfWidgetFormFilterInput(),
      'rsq_consequence' => new sfWidgetFormFilterInput(),
      'rsq_tache'       => new sfWidgetFormFilterInput(),
      'rsq_planif_eval' => new sfWidgetFormFilterInput(),
      'rsq_date_eval'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'rsq_tendance'    => new sfWidgetFormFilterInput(),
      'rsq_date_app'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'rsq_prj_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('projet'), 'column' => 'prj_id')),
      'rsq_cat_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('categorie'), 'column' => 'catrsq_id')),
      'rsq_description' => new sfValidatorPass(array('required' => false)),
      'rsq_date_ident'  => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'rsq_gravite'     => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('gravite'), 'column' => 'lib_type')),
      'rsq_proba'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('probabilite'), 'column' => 'lib_type')),
      'rsq_impact'      => new sfValidatorPass(array('required' => false)),
      'rsq_consequence' => new sfValidatorPass(array('required' => false)),
      'rsq_tache'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'rsq_planif_eval' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'rsq_date_eval'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'rsq_tendance'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'rsq_date_app'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('risque_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'risque';
  }

  public function getFields()
  {
    return array(
      'rsq_id'          => 'Number',
      'rsq_prj_id'      => 'ForeignKey',
      'rsq_cat_id'      => 'ForeignKey',
      'rsq_description' => 'Text',
      'rsq_date_ident'  => 'Date',
      'rsq_gravite'     => 'ForeignKey',
      'rsq_proba'       => 'ForeignKey',
      'rsq_impact'      => 'Text',
      'rsq_consequence' => 'Text',
      'rsq_tache'       => 'Number',
      'rsq_planif_eval' => 'Number',
      'rsq_date_eval'   => 'Date',
      'rsq_tendance'    => 'Number',
      'rsq_date_app'    => 'Date',
    );
  }
}
